﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BluePumpkin.Library.AppCode.Context;

namespace BluePumpkin.Library
{
    class ParticipationManager
    {
        public void Add(ParticipantsOnRequests participation)
        {
            using (BdbContext DBContext = new BdbContext())
            {
                ParticipantsOnRequests _participation = new ParticipantsOnRequests
                {
                    EventId = participation.EventId,
                    UserId = participation.UserId
                };

                DBContext.ParticipantsOnRequests.Add(_participation);
                DBContext.SaveChanges();

            }
        }
        public void Update(ParticipantsOnRequests participation)
        {
            using (BdbContext DBContext = new BdbContext())
            {
                var participationReq = DBContext.ParticipantsOnRequests.Single(x => x.Id == participation.Id);
               
                   participationReq.EventId = participation.EventId;
                   participationReq.UserId = participation.UserId;
                   participationReq.StatusId = participation.StatusId;
                

                
                DBContext.SaveChanges();

            }
        }

        public void Delete(ParticipantsOnRequests participation)
        {
            using (BdbContext DBContext = new BdbContext())
            {
                var _faqAns = DBContext.ParticipantsOnRequests.Single(x => x.Id == participation.Id);

                _faqAns.StatusId = participation.StatusId;
                DBContext.SaveChanges();
            }
        }
    }
}
